﻿//-----------------------------------------------------------------------
// <copyright file="GuildMemberHelper.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository;
using GateShift.Common.Repository.Interfaces.DataInterfaces;
using GateShift.Common.Repository.Interfaces.Repositories;
using GateShift.Services.GameData.Entities;

#endregion

namespace GateShift.Testing.Services.GameData.Helpers
{
    /// <summary>
    /// Static Unit Test Helper Class for GuildMember Entities
    /// </summary>
    internal static class GuildMemberHelper
    {
        /// <summary>
        /// Creates a guild member ready to save to the database
        /// </summary>
        /// <returns>IGuildMemberData with unique default values</returns>
        public static IGuildMemberData CreateGuildMember()
        {
            return CreateGuildMember(
                CharacterHelper.CreateDBCharacter().ID,
                GuildHelper.CreateDBGuild().ID,
                GuildRankHelper.CreateDBGuildRank().ID);
        }

        /// <summary>
        /// Creates a guild member ready to save to the database
        /// </summary>
        /// <param name="characterID">CharacterID to associate the member with</param>
        /// <param name="guildID">GuildID to associate the member with</param>
        /// <param name="rankID">RankID to associate the member with</param>
        /// <returns>IGuildMemberData with unique default values</returns>
        public static IGuildMemberData CreateGuildMember(Identity characterID, Identity guildID, Identity rankID)
        {
            GuildMember guildMember = new GuildMember
                                          {
                                              CharacterID = characterID,
                                              DateJoined = DateTime.UtcNow,
                                              GuildID = guildID,
                                              RankID = rankID
                                          };

            return guildMember;
        }

        /// <summary>
        /// Creates a guild member ready pre-saved to the database
        /// </summary>
        /// <returns>IGuildMemberData with unique default values</returns>
        public static IGuildMemberData CreateDBGuildMember()
        {
            return CreateDBGuildMember(
                CharacterHelper.CreateDBCharacter().ID,
                GuildHelper.CreateDBGuild().ID,
                GuildRankHelper.CreateDBGuildRank().ID);
        }

        /// <summary>
        /// Creates a guild rank ready pre-saved to the database
        /// </summary>
        /// <param name="characterID">CharacterID to associate the member with</param>
        /// <param name="guildID">GuildID to associate the member with</param>
        /// <param name="rankID">RankID to associate the member with</param>
        /// <returns>GuildRank with unique default values</returns>
        public static IGuildMemberData CreateDBGuildMember(Identity characterID, Identity guildID, Identity rankID)
        {
            GuildMember guildMember = (GuildMember)CreateGuildMember(characterID, guildID, rankID);

            DBHelper.Provider.GetRepository<IGuildMemberRepository>().Save(guildMember);

            return guildMember;
        }
    }
}